local skill = fk.CreateSkill{
  name = "action__jinnao_skill",
}

Fk:loadTranslationTable{
  ["action__jinnao"] = "金铙",
  ["action__jinnao_skill"] = "金铙",
  [":action__jinnao"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：你 <br /><b>效果</b>：选择一名其他角色，与其各获得一个“金”标记（当你受到伤害时，移除一个“金”防止此伤害）。（不可响应）",
  ["#action__jinnao_skill"] = "选择一名其他角色，与其各获得一个“金”标记（当你受到伤害时，移除一个“金”防止此伤害）",
  ["@action__jinnao"] = "金",
}


skill:addEffect("cardskill", {
  mute = true,
  name = "action__jinnao",
  prompt = "#action__jinnao_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    cardUseEvent.disresponsiveList = table.simpleClone(Fk:currentRoom().players)
    if not cardUseEvent.tos or #cardUseEvent.tos == 0 then
      cardUseEvent.tos = { cardUseEvent.from }
    end
  end,
  on_effect = function(self, room, effect)
    local to = room:askToChoosePlayers(effect.to, {
      min_num = 1,
      max_num = 1,
      targets = room:getOtherPlayers(effect.to),
      skill_name = self.name,
      cancelable = false,
      prompt = "选择一名其他角色，与其各获得一个“金”标记（当你受到伤害时，移除一个“金”防止此伤害）",
    })
    if #to > 0 then
      room:addPlayerMark(effect.to, "@action__jinnao")
      room:addPlayerMark(to[1], "@action__jinnao")
    end
  end,
})


skill:addEffect(fk.DamageInflicted, {
  mute = true,
  global = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@action__jinnao") > 0
  end,
  on_use = function(self, event, target, player, data)
    player.room:removePlayerMark(player, "@action__jinnao")
    data:preventDamage()
  end,
})


return skill